package com.hdax.dmw.order.listener;

import com.hdax.dmw.entity.order.Order;
import com.hdax.dmw.order.service.OrderService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RabbitListener(queues = "dm_order_dlx_queue")
@Component
public class OrderListener {

    @Autowired
    private OrderService orderService;

    @RabbitHandler
    public void consume(Channel channel, Message message, String orderNo){
        //根据订单编号查询订单
        Order order = orderService.detail(orderNo);
        //判断当前订单的状态
        if(order.getOrderType() == 0){
            order.setOrderType(-1);
            orderService.updateById(order);
            //联系人删除
            //座位释放
        }
    }
}
